<?php
$op = $_GET["op"];
$val = $_GET["val"];
$index = -1;
$indexValue = null;
if($f = file("cfg/config.cfg")){
	foreach($f as $k=>$v){
		if(!preg_match('/^#/',$v)){
			$tmp = explode("=",$v,2);
			if(trim($tmp[0]) == $op){
				$index = $k;
				$indexValue = trim($tmp[1]);
				break;
			}
		}
	}
}

$f[$index] = $op."=".$val;
$f = implode("\n",$f);

if($fp = fopen("cfg/config.cfg","w")){
	fwrite($fp,$f);
}

?>